import 'package:get/get.dart';
import 'package:oli/services/Apis.dart';
import 'package:oli/bean/ApiResponse.dart';
import 'package:oli/pages/main/mine/logic.dart';
import 'package:oli/services/ApiService.dart';
import 'package:oli/utils/Util.dart';
import 'state.dart';

class MainLogic extends GetxController {
  final MainState state = MainState();
  final myLogicState = Get.find<MineLogic>().state;

  @override
  Future<void> onInit() async {
    super.onInit();
    try {
      ApiResponse rest = await ApiService.postRequest(Apis.init, {});
      if (rest.code == 2000) {
        myLogicState.serveUPDown.value = true;
      }
    } catch (e) {
      myLogicState.serveUPDown.value = false;
      toastCenter('服务端未连接成功: 建议切换网络或者联系管理员!');
    }
  }
}
